package com.zucc.eye;

import com.alibaba.fastjson.JSONObject;
import com.zucc.eye.mqtt.MqttConfig;
import com.zucc.eye.mqtt.MqttUtil;
import com.zucc.eye.mqtt.PushClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

@SpringBootApplication
@EnableConfigurationProperties
@Slf4j
public class Application {

    public static void main(String[] args) throws InterruptedException {
        SpringApplication.run(Application.class, args);
        //MqttUtil.subscribeAll();
        //mqttStart();
    }

    static  void mqttStart() throws InterruptedException {
        PushClient client = PushClient.getInstance();
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("a","1");
        jsonObject.put("b","2");
        String string = jsonObject.toString();
        client.publish("xxx",string);
        //1s   10w
        //10ws
        //10ws/3600 ==27h
        int cnt=0;
        int maxCnt=100000;
        while (true){
            //Time.s

            client.publish("xxx",string);
            Thread.sleep(20);
            //0.5 h
            cnt++;
            if(cnt>=100000){
                log.info("到达 {} 条数据了",maxCnt);
                break;
            }
        }
    }

}
